package leetcode_100;

public class Pow_50 {

	public static void main(String[] args) {
		Pow_50 test=new Pow_50();
		System.out.println(Math.pow(2, Integer.MIN_VALUE));
		System.out.println(test.myPow(2.1, 3));
		System.out.println(test.myPow(Integer.MAX_VALUE, Integer.MIN_VALUE));
	}
	
	public double myPow(double x, int n) {
		if(n==Integer.MIN_VALUE){
            double temp = myPow(x, n>>1);
            return temp*temp;
        }
        if(n<0) return 1/myPow(x, -n);
        if(n==0) return 1;
        double temp=myPow(x, n/2);
        if(n%2==0)//整除
            return temp*temp;
        else
            return temp*temp*x;
    }

}
